import CommonHeader from '@/components/common-header/index'
import CommonInfo from '../components/CommonInfo/index'
import ApprovalButton from '../components/Button/index'
import Field from '../components/Field/index'
import Textarea from '../components/Textarea/index'
import AfterDateSelect from '../components/AfterDateSelect/index'
import BeforeDateSelect from '../components/BeforeDateSelect/index'
export default {
  name: 'SeparationApproval',
  components: {
    CommonHeader,
    CommonInfo,
    ApprovalButton,
    Field,
    Textarea,
    AfterDateSelect,
    BeforeDateSelect,
  },
  data() {
    return {
      warn: '您有未填写的数据',
      approval: {
        connectEmployee: '',
        job: '',
        entryDate: '',
        separationDate: '',
        separationReason: '',
      },
    }
  },
  methods: {
    getConnectEmployee(data) {
      this.approval.connectEmployee = data
    },
    getJob(data) {
      this.approval.job = data
    },
    getEntryDate(data) {
      this.approval.entryDate = data
    },
    getSeparationDate(data) {
      this.approval.separationDate = data
    },
    getSeparationReason(data) {
      this.approval.separationReason = data.mp.detail.__args__[0]
    },
  },
  watch: {
    approval: {
      deep: true,
      handler: function(newV, oldV) {
        for (let key in newV) {
          if (!newV[key]) {
            return
          }
        }
        this.warn = ''
      },
    },
  },
}
